<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>照片展示</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        #images {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            padding: 10px;
        }

        .image-container {
            width: calc(50% - 10px);
            margin-bottom: 10px;
            position: relative;
            cursor: pointer;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .image-container img {
            width: 100%;
            height: auto;
            display: block;
        }

        /* 放大效果 */
        .modal {
            display: none;
            position: fixed;
            z-index: 1;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgba(0, 0, 0, 0.9);
            justify-content: center;
            align-items: center;
        }

        .modal-content {
            max-width: 80%;
            max-height: 80%;
        }

        .modal-content img {
            width: 100%;
            height: auto;
            display: block;
        }

        .close {
            position: absolute;
            top: 15px;
            right: 35px;
            color: #f1f1f1;
            font-size: 40px;
            font-weight: bold;
            cursor: pointer;
        }

        @media only screen and (max-width: 700px) {
            .modal-content {
                width: 100%;
            }
        }

        .button {
            display: block;
            width: 80%;
            max-width: 300px;
            padding: 15px 20px;
            margin: 10px auto;
            font-size: 18px;
            color: #fff;
            background-color: #28a745;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            text-decoration: none;
            text-align: center;
        }

        .button:hover {
            background-color: #218838;
        }
    </style>
    <link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.min.css">
</head>
<body>
<a href="hsz.html" class="button">返回</a>

<div id="images"></div>

<div id="myModal" class="modal">
    <span class="close">&times;</span>
    <div class="modal-content">
        <img id="modalImg">
    </div>
</div>

<script>
    document.addEventListener('DOMContentLoaded', () => {
        const imagesDiv = document.getElementById('images');

        fetch('https://www.ncxdd.com/ncxdd/photo/hsz')
            .then(response => response.json())
            .then(data => {
                data.data.forEach(image => {
                    const imgContainer = document.createElement('div');
                    imgContainer.classList.add('image-container');

                    const img = document.createElement('img');
                    img.src = image.thumbnail;  // 使用缩略图

                    img.addEventListener('click', () => {
                        document.getElementById('modalImg').src = image.original;  // 使用原图
                        document.getElementById('myModal').style.display = 'flex';
                    });

                    imgContainer.appendChild(img);
                    imagesDiv.appendChild(imgContainer);
                });
            })
            .catch(error => console.error('Error:', error));

        // 点击放大图片
        const modal = document.getElementById('myModal');
        const span = document.getElementsByClassName('close')[0];

        span.onclick = function() {
            modal.style.display = 'none';
        };

        window.onclick = function(event) {
            if (event.target == modal) {
                modal.style.display = 'none';
            }
        };
    });
</script>
</body>
</html>
